﻿namespace EyeOpen.CsvParser.Windows
{
	using System.Collections.Generic;
	using System.Linq;

	public class CustomerParser
	{
		public IEnumerable<Customer> Parse(string csv)
		{
			return
				csv
					.Split('\n')
					.Select(CustomerFromLine)
					.ToList();
		}

		private Customer CustomerFromLine(string line)
		{
			var values = line.Split(',');

			return 
				new Customer
					{
						Name = values[0],
						Age = int.Parse(values[1])
					};
		}
	}
}